package siru;

import Controller.BCrypt;
import DAOs.*;
import DAOs.exceptions.NonexistentEntityException;
import Entity.*;
import Interface.Windows.MainWindow;
import Interface.Windows.UserValidation;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author USUARIO
 */
public class SIRU {
    private EntityManagerFactory emf;
    
    private void initEMF(){
        Map<String, String> properties = new HashMap<>();
        properties.put("javax.persistence.jdbc.user", "root");
       // System.out.println("PASO POR INIT EMF");
        properties.put("javax.persistence.jdbc.password", "root");
        emf = Persistence.createEntityManagerFactory("SIRUPU", properties);        
    }
    
    public SIRU() throws NonexistentEntityException {
        this.initEMF();
        UserJpaController up = new UserJpaController(emf);
        //up.findUser(new Long("0"));
        UserValidation uv = new UserValidation(emf);
        uv.setLocationRelativeTo(null);
        uv.setVisible(true);
    }

    public static void main(String[] args) throws NonexistentEntityException {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        new SIRU();
    }
}
